package com.zjhcsoft.komm;

import com.zjhcsoft.komm.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.List;
import java.util.Arrays;

@Name("userList")
public class UserList extends EntityQuery {

	private static final String[] RESTRICTIONS = {
			"lower(user.department) like concat(lower(#{userList.user.department}),'%')",
			"lower(user.email) like concat(lower(#{userList.user.email}),'%')",
			"lower(user.password) like concat(lower(#{userList.user.password}),'%')",
			"lower(user.phone) like concat(lower(#{userList.user.phone}),'%')",
			"lower(user.realName) like concat(lower(#{userList.user.realName}),'%')",
			"lower(user.username) like concat(lower(#{userList.user.username}),'%')",};

	private User user = new User();

	@Override
	public String getEjbql() {
		return "select user from User user";
	}

	@Override
	public Integer getMaxResults() {
		return 25;
	}

	public User getUser() {
		return user;
	}

	@Override
	public List<String> getRestrictions() {
		return Arrays.asList(RESTRICTIONS);
	}

}
